{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from selenium.webdriver import Chrome\n",
    "import time\n",
    "import csv\n",
    "from selenium.webdriver.common.keys import Keys\n",
    "page=5\n",
    "def seach(key):\n",
    "    web.maximize_window()\n",
    "    time.sleep(0.1)\n",
    "    web.find_element_by_xpath('//*[@id=\"header-search\"]/div[1]/input[2]').send_keys(key)\n",
    "    time.sleep(0.5)\n",
    "    web.find_element_by_xpath('//*[@id=\"header-search\"]/div[2]/button').click()\n",
    "    time.sleep(0.5)\n",
    "def product():\n",
    "   \n",
    "    \n",
    "    res=web.find_elements_by_xpath('//div[@class=\"task_class_list_li\"]/div[@class=\"task_class_list_li_box\"]')\n",
    "    #res=web.find_elements_by_xpath('/html/body/div[10]/div[1]/div[2]/div[4]/div/div[1]/h3/a')\n",
    "    for i in res:\n",
    "        \n",
    "        global page\n",
    "        print(page)\n",
    "        \n",
    "        web.implicitly_wait(3)\n",
    "        url='/html/body/div[10]/div[1]/div[2]/div[4]/div%s/div[1]/h3/a'%([page])\n",
    "    \n",
    "        print(url)\n",
    "        web.find_element_by_xpath(url).send_keys(Keys.ENTER)\n",
    "        page+=1\n",
    "        time.sleep(1)\n",
    "        \n",
    "        \n",
    "        time.sleep(1)\n",
    "        web.switch_to.window(web.window_handles[-1])\n",
    "        name=web.find_element_by_xpath('/html/body/div[10]/div/div[1]/div[1]/div[2]/div[1]/a').text\n",
    "        work=web.find_element_by_xpath('/html/body/div[10]/div/div[1]/div[1]/div[2]/div[3]').text\n",
    "        money=web.find_element_by_xpath('/html/body/div[10]/div/div[1]/div[3]/div[1]/div/div[2]/div[1]/span[1]/span').text\n",
    "        finall=web.find_element_by_xpath('/html/body/div[10]/div/div[1]/div[3]/div[4]/div[1]/div[2]').text\n",
    "        print(name,work,money,finall)\n",
    "        print('*'*50)\n",
    "        web.close()\n",
    "        web.switch_to.window(web.window_handles[0])\n",
    "        time.sleep(2)\n",
    "        \n",
    "       \n",
    "        \n",
    "    \n",
    "    \n",
    "#     for i in res:\n",
    "#         i.find_element_by_xpath('.//h3[@class=\"a2\"]/a').click().perform()\n",
    "#         #确定窗口\n",
    "#         time.sleep(1)\n",
    "#         web.switch_to.window(web.window_handles[-1])\n",
    "#         name=web.find_element_by_xpath('/html/body/div[10]/div/div[1]/div[1]/div[2]/div[1]/a').text\n",
    "#         work=web.find_element_by_xpath('/html/body/div[10]/div/div[1]/div[1]/div[2]/div[3]').text\n",
    "#         money=web.find_element_by_xpath('/html/body/div[10]/div/div[1]/div[3]/div[1]/div/div[2]/div[1]/span[1]/span').text\n",
    "#         finall=web.find_element_by_xpath('/html/body/div[10]/div/div[1]/div[3]/div[4]/div[1]/div[2]').text\n",
    "#         print(name,work,money,finall)\n",
    "#         print('*'*50)\n",
    "#         time.sleep(3)\n",
    "#         web.close()\n",
    "#         web.switch_to.window(web.window_handles[0])\n",
    "#         time.sleep(10)\n",
    "        \n",
    "#     web.find_element_by_xpath('/html/body/div[10]/div[1]/div[2]/div[4]/div[1]/div[1]/h3/a').click()\n",
    "\n",
    "\n",
    "\n",
    "def main():\n",
    "    seach(key)\n",
    "    product()\n",
    "    \n",
    "\n",
    "if __name__=='__main__':\n",
    "    web=Chrome()\n",
    "    web.get('https://www.epwk.com/')\n",
    "    key=input('请输入内容: ')\n",
    "    main()\n",
    "    \n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "class demo():\n",
    "    pass\n",
    "def one():\n",
    "    j=o\n",
    "    for i in range(3)\n",
    "    j+=1\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
